package com.commons.web.controller;


import com.baomidou.mybatisplus.core.conditions.query.*;
import com.commons.service.entity.*;
import com.commons.service.service.*;
import com.commons.service.service.impl.*;
import com.commons.tools.utils.*;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.*;
import org.springframework.web.bind.annotation.*;

import java.util.*;

/**
 * <p>
 * 一对多，2张表，字段冗余或者加一张关系表
 * </p>
 *
 * @author robot
 * @since 2023-12-05
 */
@RestController
@RequestMapping("/service/classes")
public class ClassesController {
    @Autowired
    private IClassesService classesService;
    @Autowired
    private IUserService userService;

    @ApiOperation("根据用户查询班级列表信息")
    @GetMapping("/get_list")
    public Result<Classes> getListByUser(@RequestParam Integer userId) {
        // 查询关系表或字段冗余表
        LambdaQueryWrapper<Classes> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Classes::getUserId, userId);
        Classes classes = classesService.getOne(wrapper);

        return Result.ok(classes);
    }

}

